package com.macro.mall.common.exception;

import com.macro.mall.common.code.error.IErrorCode;

/**
 * 定义通用异常类
 * Created by macro on 2020/2/27.
 */
public class MallCommonException extends RuntimeException {
    private IErrorCode errorCode;

    public MallCommonException(IErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }

    // 新增异常构造，errorCode + Throwable
    public MallCommonException(IErrorCode errorCode, Throwable cause) {
        super(errorCode.getMessage(),cause);
        this.errorCode = errorCode;
    }

    public MallCommonException(String message) {
        super(message);
    }

    public MallCommonException(Throwable cause) {
        super(cause);
    }

    public MallCommonException(String message, Throwable cause) {
        super(message, cause);
    }

    public IErrorCode getErrorCode() {
        return errorCode;
    }
}
